package com.stephentuso.welcome;

import ohos.app.Context;

/**
 * Created by stephentuso on 1/22/16.
 * Provides a way to correctly close a welcome screen
 */
public class WelcomeFinisher {

    private Context mContext;

    /**
     * @param mContext A context that is a custom page in a {@link WelcomeAbility}
     */
    public WelcomeFinisher(Context mContext) {
        this.mContext = mContext;
    }

    /**
     * Completes the welcome screen the provided context is a part of.
     * Checks that the ability is an instance of {@link WelcomeAbility} to avoid errors if
     * this is used in the wrong place.
     */
    public void finish() {
        if (mContext instanceof WelcomeAbility) {
            WelcomeAbility welcomeAbility = (WelcomeAbility) mContext;
            welcomeAbility.completeWelcomeScreen();
        }
    }

}
